import { createRouter, createWebHistory } from 'vue-router'

import navbarConfig from './navbar.config'
import pageConfig from './page.config'
import doorConfig from './door.config'

import MainLayout from '@/layout/main.vue'
import PageLayout from '@/layout/page.vue'

const router = createRouter({
	history: createWebHistory(import.meta.env.BASE_URL),
	routes: [
		{
			path: '',
			component: MainLayout,
			redirect: navbarConfig[0] || '/404',
			children: navbarConfig
		},
		{
			path: '',
			component: PageLayout,
			children: pageConfig
		},
		{
			path: '',
			component: PageLayout,
			children: doorConfig
		},
		{
			name: 'login',
			path: '/login',
			component: () => import('@/views/Login.vue'),
			meta: {
				title: '登录',
				isNavBar: false
			}
		},
		{
			name: 'welcome',
			path: '/welcome',
			component: () => import('@/views/start/index.vue')
		}
	]
})

export default router
